package com.seashop.feign.fallback;

import com.seashop.response.ResponseBase;
import com.seashop.feign.UserFeignClient;
import com.seashop.request.LoginRequestParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author moredln
 * @desc 用户服务调用失败处理
 * @date 2020-11-11 10:32
 */
@Component
@Slf4j
public class UserFeignClientFallBack implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient(){
            @Override
            public ResponseBase getVerificationCode(String mobile, String areaCode, String countryCode) {
                log.info("调用用户服务获取验证码失败");
                return null;
            }

            @Override
            public ResponseBase loginOrRegister(LoginRequestParam param) {
                log.info("调用用户服务登陆注册失败");
                return null;
            }

            @Override
            public ResponseBase queryMemberLevel(Integer userId) {
                log.info("调用用户服务查询会员等级失败");
                return null;
            }
        };
    }
}
